package com.meta.platform.login.plus.security;

import com.meta.platform.login.plus.security.provider.LoginSimpleAuthenticationProvider;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.DefaultSecurityFilterChain;
import org.springframework.stereotype.Component;

import com.meta.framework.common.utils.spring.SpringUtils;

import lombok.extern.slf4j.Slf4j;

/**
 * 验证码安全配置
 *
 * @author pengjianfeng
 * @version 1.0
 * @date 2021/1/12 9:36 上午
 */
@Slf4j
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class LoginSimpleAuthenticationSecurityConfig extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> {
    
    public LoginSimpleAuthenticationSecurityConfig() {
        log.info("---------VCodeAuthenticationSecurityConfig start---------------");
    }
    
    @Override
    public void configure(HttpSecurity http)
        throws Exception {
        // 将短信验证码校验器注册到 HttpSecurity
        http.authenticationProvider(SpringUtils.getBean(LoginSimpleAuthenticationProvider.class));
    }
}
